package com.sdhs.paas.gateway.config;

import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.config.MemoryUnit;
import org.springframework.context.annotation.Bean;

@org.springframework.context.annotation.Configuration
public class CacheConfig
{
  @Bean({"ame-ehcacheManager"})
  public CacheManager ehcacheManager()
  {
    net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();

    CacheConfiguration cacheConfiguration = new CacheConfiguration();

    cacheConfiguration.maxBytesLocalHeap(100L, MemoryUnit.MEGABYTES);

    cacheConfiguration.setTimeToLiveSeconds(0L);

    configuration.defaultCache(cacheConfiguration);
    configuration.dynamicConfig(false);
    return CacheManager.newInstance(configuration);
  }
}
